home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 66
/
Vol 66.iso
/
games
/
bob_espo.swf
/
scripts
/
__Packages
/
CenterScreen.as
< prev
next >
Wrap
Text File
|
2013-04-24
|
10KB
|
312 lines
class CenterScreen extends State
{
static var sSTATE_IDLE = "Idle";
static var sSTATE_TURNLEFT = "TurnLeft";
static var sSTATE_TURNRIGHT = "TurnRight";
static var sSTATE_MOVEFORWARD = "MoveForward";
static var sSTATE_TURN180_LEFT = "Turn180Left";
static var sSTATE_TURN180_RIGHT = "Turn180Right";
static var sSTATE_TURN180_UP = "Turn180Up";
static var sSTATE_TURN180_DOWN = "Turn180Down";
static var sSTATE_MG_BREAKWALL = "MG_BreakTheWall";
static var sSTATE_MG_JELLYFISHSWARM = "MG_JellyFishSwarm";
static var sSTATE_MG_PUSHBUS = "MG_PushTheBus";
function CenterScreen(_mcRef)
{
super(_mcRef);
this.oCurrentMinigame = null;
this.oCurrentAlgae = null;
this.oCurrentJelly = null;
this.oCurrentWall = null;
this.oInterface = new Interface(this.mcRef.mcInterface);
this.oTransition = new MinigameTransition(this.mcRef.mcTransition);
this.sNextState = "";
this.setState(CenterScreen.sSTATE_IDLE);
}
function cleanUp()
{
super.cleanUp();
if(this.oCurrentMinigame != null)
{
this.oCurrentMinigame.destroyMiniGame(true);
delete this.oCurrentMinigame;
this.oCurrentMinigame = null;
}
if(this.oCurrentAlgae != null)
{
this.oCurrentAlgae.cleanUp();
delete this.oCurrentAlgae;
}
if(this.oCurrentJelly != null)
{
this.oCurrentJelly.cleanUp();
delete this.oCurrentJelly;
}
if(this.oCurrentWall != null)
{
this.oCurrentWall.cleanUp();
delete this.oCurrentWall;
}
}
function startBreakTheWall(_oWall)
{
if(!this.isInMiniGame())
{
this.oCurrentWall = _oWall;
this.goTo(CenterScreen.sSTATE_MG_BREAKWALL);
this.setState(CenterScreen.sSTATE_IDLE);
CTRLGame.getRef().Screen.getInterface().pauseTime();
CTRLGame.getRef().stopAnimElements();
}
}
function startJellyFishSwarm(_oJelly)
{
if(!this.isInMiniGame())
{
this.oCurrentJelly = _oJelly;
this.goTo(CenterScreen.sSTATE_MG_JELLYFISHSWARM);
this.setState(CenterScreen.sSTATE_IDLE);
CTRLGame.getRef().Screen.getInterface().pauseTime();
CTRLGame.getRef().stopAnimElements();
}
}
function startPushTheBus(_oAlgae)
{
if(!this.isInMiniGame())
{
this.oCurrentAlgae = _oAlgae;
this.goTo(CenterScreen.sSTATE_MG_PUSHBUS);
this.setState(CenterScreen.sSTATE_IDLE);
CTRLGame.getRef().Screen.getInterface().pauseTime();
CTRLGame.getRef().stopAnimElements();
}
}
function isInMiniGame()
{
var _loc2_ = false;
if(this.sState == CenterScreen.sSTATE_MG_BREAKWALL || (this.sState == CenterScreen.sSTATE_MG_JELLYFISHSWARM || (this.sState == CenterScreen.sSTATE_MG_PUSHBUS || !this.oTransition.isInIdle())))
{
_loc2_ = true;
}
return _loc2_;
}
function manageAnim(_nNewDir, _nLastDir, _nMovement)
{
if(_nMovement == 0)
{
if(this.isSkippableState())
{
this.setState(CenterScreen.sSTATE_IDLE);
}
else
{
this.sNextState = CenterScreen.sSTATE_IDLE;
}
}
else if(_nNewDir == CTRLGame.nDIR_DOWN && _nLastDir == CTRLGame.nDIR_DOWN || (_nNewDir == CTRLGame.nDIR_UP && _nLastDir == CTRLGame.nDIR_UP || (_nNewDir == CTRLGame.nDIR_LEFT && _nLastDir == CTRLGame.nDIR_LEFT || _nNewDir == CTRLGame.nDIR_RIGHT && _nLastDir == CTRLGame.nDIR_RIGHT)))
{
if(this.isSkippableState())
{
this.setState(CenterScreen.sSTATE_MOVEFORWARD);
}
else
{
this.sNextState = CenterScreen.sSTATE_MOVEFORWARD;
}
}
else if(_nNewDir == CTRLGame.nDIR_DOWN && _nLastDir == CTRLGame.nDIR_UP)
{
if(this.isSkippableState())
{
this.setState(CenterScreen.sSTATE_TURN180_DOWN);
}
else
{
this.sNextState = CenterScreen.sSTATE_TURN180_DOWN;
}
}
else if(_nNewDir == CTRLGame.nDIR_RIGHT && _nLastDir == CTRLGame.nDIR_LEFT)
{
if(this.isSkippableState())
{
this.setState(CenterScreen.sSTATE_TURN180_LEFT);
}
else
{
this.sNextState = CenterScreen.sSTATE_TURN180_LEFT;
}
}
else if(_nNewDir == CTRLGame.nDIR_LEFT && _nLastDir == CTRLGame.nDIR_RIGHT)
{
if(this.isSkippableState())
{
this.setState(CenterScreen.sSTATE_TURN180_RIGHT);
}
else
{
this.sNextState = CenterScreen.sSTATE_TURN180_RIGHT;
}
}
else if(_nNewDir == CTRLGame.nDIR_UP && _nLastDir == CTRLGame.nDIR_DOWN)
{
if(this.isSkippableState())
{
this.setState(CenterScreen.sSTATE_TURN180_UP);
}
else
{
this.sNextState = CenterScreen.sSTATE_TURN180_UP;
}
}
else if(_nNewDir == CTRLGame.nDIR_DOWN && _nLastDir == CTRLGame.nDIR_LEFT || (_nNewDir == CTRLGame.nDIR_LEFT && _nLastDir == CTRLGame.nDIR_UP || (_nNewDir == CTRLGame.nDIR_UP && _nLastDir == CTRLGame.nDIR_RIGHT || _nNewDir == CTRLGame.nDIR_RIGHT && _nLastDir == CTRLGame.nDIR_DOWN)))
{
if(this.isSkippableState())
{
this.setState(CenterScreen.sSTATE_TURNLEFT);
}
else
{
this.sNextState = CenterScreen.sSTATE_TURNLEFT;
}
}
else if(_nNewDir == CTRLGame.nDIR_DOWN && _nLastDir == CTRLGame.nDIR_RIGHT || (_nNewDir == CTRLGame.nDIR_RIGHT && _nLastDir == CTRLGame.nDIR_UP || (_nNewDir == CTRLGame.nDIR_UP && _nLastDir == CTRLGame.nDIR_LEFT || _nNewDir == CTRLGame.nDIR_LEFT && _nLastDir == CTRLGame.nDIR_DOWN)))
{
if(this.isSkippableState())
{
this.setState(CenterScreen.sSTATE_TURNRIGHT);
}
else
{
this.sNextState = CenterScreen.sSTATE_TURNRIGHT;
}
}
}
function setState(_sState)
{
var _loc4_ = this.sState;
super.setState(_sState);
if(this.sState == CenterScreen.sSTATE_MG_BREAKWALL)
{
this.oCurrentMinigame = new MiniGames.BTW.BreakTheWallMG(this.mcRef.mcState);
}
else if(this.sState == CenterScreen.sSTATE_MG_JELLYFISHSWARM)
{
this.oCurrentMinigame = new MiniGames.JFS.JellyFishSwarmMG(this.mcRef.mcState);
}
else if(this.sState == CenterScreen.sSTATE_MG_PUSHBUS)
{
this.oCurrentMinigame = new MiniGames.PTB.PushTheBusMG(this.mcRef.mcState);
}
if(_loc4_ == CenterScreen.sSTATE_MG_BREAKWALL || (_loc4_ == CenterScreen.sSTATE_MG_JELLYFISHSWARM || _loc4_ == CenterScreen.sSTATE_MG_PUSHBUS))
{
if(this.sState == CenterScreen.sSTATE_IDLE)
{
CTRLGame.getRef().Screen.getInterface().unPauseTime();
CTRLGame.getRef().resumeAnimElements();
}
}
}
function getInterface()
{
return this.oInterface;
}
function isSkippableState()
{
var _loc2_ = false;
if(this.sState == CenterScreen.sSTATE_MOVEFORWARD || this.sState == CenterScreen.sSTATE_IDLE)
{
_loc2_ = true;
}
return _loc2_;
}
function manageEndMiniGame()
{
if(this.oCurrentMinigame.isFinished() && this.oCurrentMinigame != null)
{
this.oCurrentMinigame.destroyMiniGame();
delete this.oCurrentMinigame;
this.oCurrentMinigame = null;
if(this.sState == CenterScreen.sSTATE_MG_BREAKWALL)
{
this.oCurrentWall.cleanUp();
delete this.oCurrentWall;
this.oCurrentWall = null;
}
else if(this.sState == CenterScreen.sSTATE_MG_JELLYFISHSWARM)
{
this.oCurrentJelly.cleanUp();
delete this.oCurrentJelly;
this.oCurrentJelly = null;
}
else
{
this.oCurrentAlgae.cleanUp();
delete this.oCurrentAlgae;
this.oCurrentAlgae = null;
}
this.goTo(CenterScreen.sSTATE_IDLE);
}
}
function manageTempState()
{
if(this.stateFinished())
{
if(this.sNextState != "")
{
this.setState(this.sNextState);
this.sNextState = "";
}
else
{
this.setState(CenterScreen.sSTATE_MOVEFORWARD);
}
}
}
function goTo(_sState)
{
this.oTransition.goTo(_sState);
}
function Idle()
{
}
function MoveForward()
{
}
function TurnLeft()
{
this.manageTempState();
}
function TurnRight()
{
this.manageTempState();
}
function Turn180Left()
{
this.manageTempState();
}
function Turn180Right()
{
this.manageTempState();
}
function Turn180Up()
{
this.manageTempState();
}
function Turn180Down()
{
this.manageTempState();
}
function MG_BreakTheWall()
{
this.manageEndMiniGame();
}
function MG_JellyFishSwarm()
{
this.manageEndMiniGame();
}
function MG_PushTheBus()
{
this.manageEndMiniGame();
}
}